Test/dark mode brightness assertions#2097
Merged
dscho merged 2 commits intogit:gh-pagesfrom Oct 2, 2025
Merged
Conversation
Replace pixel-based screenshot comparisons with perceptually accurate brightness assertions using ITU-R BT.709 relative luminance (0.2126R + 0.7152G + 0.0722B), normalized to [0,1]. Assert light mode ≈0.85 and dark mode ≈0.25. Signed-off-by: rafaeljohn9 <rafaeljohb@gmail.com>
Signed-off-by: rafaeljohn9 <rafaeljohb@gmail.com>
dscho
approved these changes
Oct 2, 2025
Member
dscho
left a comment
There was a problem hiding this comment.
Very nice!
The only addition (which I will make in the merge commit's message) is to talk in the commit message about what motivated this change: The PR build failure in #2088 that shouldn't have included a test failure (pointing out that the assertions were ill-specified).
dscho
added a commit
that referenced
this pull request
Feb 20, 2026
## Changes - Ties up a few loose ends of #2097 ## Context In e3c066e ("test: verify dark/light mode via normalized relative luminance"), the dark mode test was rewritten to use an average-brightness approach instead of comparing against reference screenshots. Follow-up commit f3d3240 ("test: remove screenshot snapshots for dark/light mode tests") removed the tracked Linux snapshot images, but left behind the `.gitignore` entries that suppressed the non-Linux (macOS and Windows) snapshots, as well as the README note explaining that the first test run on those platforms would "fail" while generating the baseline screenshots. Since `toHaveScreenshot` is no longer used anywhere in the test suite, clean up these leftovers: remove the two `.gitignore` patterns for `*-darwin.png` and `*-win32.png` in the snapshots directory, and remove the now-inaccurate README paragraph about first-run screenshot failures on non-Linux platforms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
getPageBrightness()helper that computes relative luminance using the ITU-R BT.709/sRGB coefficients (0.2126*R + 0.7152*G + 0.0722*B), normalized to the[0, 1]range.0.85 ± 0.1and dark mode is0.25 ± 0.1.Context
Pixel-diff-based screenshot tests are fragile they fail on minor layout shifts, anti-aliasing changes, or browser rendering differences, even when the visual theme (light/dark) is correct.
Instead, we now verify perceived brightness using the standard definition of relative luminance from color science (per Wikipedia), which aligns with human vision sensitivity (green contributes most, blue least).
Reference: #2088 (comment)